/**
 * 
 */
package com.tc.dispatch.web.filter;

import java.io.IOException;
import java.util.Enumeration;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author cajeep
 * 
 */
public class cacheFilter implements Filter {
	FilterConfig fc; 
	/**
	 * 
	 */
	public cacheFilter() {
		// TODO Auto-generated constructor stub
	}

	public void doFilter(ServletRequest servletRequest,
			ServletResponse servletResponse, FilterChain filterChain)
			throws IOException, ServletException {
		HttpServletRequest request = (HttpServletRequest) servletRequest;
		HttpServletResponse response = (HttpServletResponse) servletResponse;

		// 得到当前请求的地址
		String currentRequestURL = request.getServletPath();

		/*System.out.println("Login check match-servlet path: "
				+ request.getServletPath());*/
		for (Enumeration e = fc.getInitParameterNames(); e.hasMoreElements();) {   
            String headerName = (String) e.nextElement();   
            response.addHeader(headerName, fc.getInitParameter(headerName));   
        }   
		filterChain.doFilter(servletRequest, servletResponse);
		return ;
	}

	public void init(FilterConfig filterConfig) throws ServletException {
		this.fc=filterConfig;
	}

	public void destroy() {
		this.fc=null;
	}

}
